<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01</title>
</head>
<body>
<script>
    /*
     * 原型链实现继承
     *
     */
    function Animal(name) {
        this.name = name;
        this.friends = ["dog","cat"];
    }

    Animal.prototype.sayName = function () {
            alert(this.name);
        }
    }

    var a1 = new Animal();
    var a2 = new Animal();
    alert(a1.sayName == a2.sayName); //true
    a1.sayName();

    alert(Animal.prototype.constructor == Animal); //true

    a1.friends.push("snake");
    alert(a2.friends); //["dog","cat"]
</script>
</body>
</html>